<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript">
        // json的定义
        var jsonObj = {
            "key1": 12,
            "key2": "adobe",
            "key3": true,
            "key4": [11, "arr", false],
            "key5": {
                "key5_1": 9527,
                "key5_2": "key5_2_va"
            },
            "key6": [{
                "key_6_1": "6527",
                "key_6_2": "key_6_2_va"
            }, {
                "key_6_1": "6527",
                "key_6_2": "key_6_2_va"
            }, {
                "key_6_1": "6527",
                "key_6_2": "key_6_2_va"
            }]
        }

        // json的访问
        console.log(jsonObj.key1)
        console.log(jsonObj.key2)
        console.log(jsonObj.key3)
        for (let i = 0; i < jsonObj.key4.length; i++) {
            console.log(jsonObj.key4[i]);

        }

        console.log("_______________")

        console.log(jsonObj.key5.key5_1)

        console.log(jsonObj.key6[0].key_6_1)

        // json对象转字符串

        var jsonObjString = JSON.stringify(jsonObj)
        alert(jsonObjString)

        // json字符串转json对象
        var jsonObj1 = JSON.parse(jsonObjString);
        alert(jsonObj1)
    </script>
</head>
<body>

</body>
</html>